package test;

import org.beian.ApiApplication;
import org.beian.fmmall.beans.CategoryVO;
import org.beian.fmmall.beans.ProductByCategoryVO;
import org.beian.fmmall.beans.ShoppingCartVO;
import org.beian.fmmall.dao.CategoryMapper;
import org.beian.fmmall.dao.ProductMapper;
import org.beian.fmmall.dao.ShoppingCartMapper;
import org.beian.fmmall.service.ProductService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.lang.invoke.VarHandle;
import java.util.ArrayList;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class test {
    @Autowired
    private CategoryMapper categoryMapper;
    @Autowired
    private ShoppingCartMapper shoppingCartMapper;

    @Autowired
    private ProductMapper productMapper;
    @Test
    public void test1(){
        List<CategoryVO> categoryVOS = categoryMapper.selectAllCategories2(0);
        for (CategoryVO c1 : categoryVOS) {
            System.out.println(c1);
            for(CategoryVO c2:c1.getCategories()){
                System.out.println("\t"+c2);
                for(CategoryVO c3:c2.getCategories()){
                    System.out.println("\t\t"+c3);
                }
            }
        }
    }
    @Test
    public void test2(){
        List<Integer> cids=new ArrayList<>();
        cids.add(17);
        cids.add(18);
        List<ShoppingCartVO> shoppingCartVOS = shoppingCartMapper.selectShopCartByCids(cids);
        for (ShoppingCartVO shoppingCartVO : shoppingCartVOS) {
            System.out.println(shoppingCartVO);
        }
    }
    @Test
    public void test3(){
        List<ProductByCategoryVO> list = productMapper.selectProsByCategory(49, 0, 7);
        for (ProductByCategoryVO productByCategoryVO : list) {
            System.out.println(productByCategoryVO);
        }
    }


}
